from flask import jsonify

import configparser

def translist(list):
    items = []
    for item in list:
        items.append(item.to_json)
    return items

# 转化字典到模型类
def toDbModel(model, jsonDict):
    for key in jsonDict:
        setattr(model, key, jsonDict[key])
    return model


def ok(data):
    res = {'code': 200, 'message': '操作成功！', 'data': data}
    return jsonify(res)


def error():
    res = {'code': 500, 'message': '程序异常！'}
    return jsonify(res)


def readConf(conf, title, tag):
    config = configparser.ConfigParser()
    config.read(conf)
    port_num = config[title][tag]
    print(port_num)


# readConf('./config.ini', 'port', 'port')